package com.guo.hui.eurekazuul;

import com.netflix.zuul.ZuulFilter;
import com.netflix.zuul.context.RequestContext;
import com.netflix.zuul.exception.ZuulException;

import javax.servlet.http.HttpServletRequest;

/**
 * @ClassName AccessFilter
 * @Description TODO
 * @Author zhengguohui
 * @Date 2018/7/18 16:45
 */
public class AccessFilter extends ZuulFilter {


    @Override
    public String filterType() {
        return "pre";
    }

    @Override
    public int filterOrder() {
        return 0;
    }

    @Override
    public boolean shouldFilter() {
        return true;
    }

    @Override
    public Object run() throws ZuulException {
        RequestContext ctx = RequestContext.getCurrentContext();
        HttpServletRequest request = ctx.getRequest();
        Object accessToken = request.getParameter("accessToken");
        if (accessToken == null) {
//            ctx.setResponseBody("没有权限!");
//            ctx.setSendZuulResponse(false);
//            ctx.setResponseStatusCode(401);
        }
        return null;
    }
}
